package leecode

import "strings"

func uncommonFromSentences(s1 string, s2 string) (result []string) {
	s1Arr := strings.Split(s1, " ")
	s2Arr := strings.Split(s2, " ")
	hash1, hash2, hashMap := make(map[string]int), make(map[string]int), make(map[string]int) //统计单词出现的次数
	for i := 0; i < len(s1Arr); i++ {
		hash1[s1Arr[i]]++
		hashMap[s1Arr[i]]++
	}
	for i := 0; i < len(s2Arr); i++ {
		hash2[s2Arr[i]]++
		hashMap[s2Arr[i]]--
	}
	for key, value := range hashMap {
		if (value == 1 || value == -1) && (hash1[key] <= 1 && hash2[key] <= 1) {
			result = append(result, key)
		}
	}
	return
}
